package com.erp.erp_servers.basic.imp;

import com.erp.erp_dao.basic.IDictionaryDao;
import com.erp.erp_entitys.basic.entity.DictionaryEntity;
import com.erp.erp_servers.basic.IDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName : DictionaryServiceImp
 * @Description : 字典接口实现层
 * @Author : lst
 * @Date: 2021-09-14 00:01
 */
@Service
public class DictionaryServiceImp implements IDictionaryService {

    /**
     * 注入字典mapper
     */
    private final IDictionaryDao dictionaryDao;

    @Autowired
    public DictionaryServiceImp(IDictionaryDao dictionaryDao) {
        this.dictionaryDao = dictionaryDao;
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public DictionaryEntity queryById(Integer id) {
        return dictionaryDao.queryById(id);
    }

    /**
     * 通过实体作为筛选条件查询
     *
     * @param dictionary 实例对象
     * @return 对象列表
     */
    @Override
    public List<DictionaryEntity> queryAll(DictionaryEntity dictionary) {
        return dictionaryDao.queryAll(dictionary);
    }

    /**
     * 新增数据
     *
     * @param dictionary 实例对象
     * @return 影响行数
     */
    @Override
    public int insert(DictionaryEntity dictionary) {
        return dictionaryDao.insert(dictionary);
    }

    /**
     * 修改数据
     *
     * @param dictionary 实例对象
     * @return 影响行数
     */
    @Override
    public int update(DictionaryEntity dictionary) {
        return dictionaryDao.update(dictionary);
    }


    /**
     * 获取字典编码
     * @param dictionary 查询条件
     * @return 字典编码
     */
    @Override
    public List<DictionaryEntity> getDictionaryCodeByQuery(DictionaryEntity dictionary) {
        return dictionaryDao.getDictionaryCodeByQuery(dictionary);
    }

    /**
     * 获取字典对象集合
     * @param dictionary 查询条件
     * @return 字典对象集合
     */
    @Override
    public List<DictionaryEntity> getDictionaryList(DictionaryEntity dictionary) {
        return dictionaryDao.getDictionaryList(dictionary);
    }
}
